<!DOCTYPE html>
<html class="x-admin-sm">
<html lang="en" xmlns:th="http://wwww.thymeleaf.org" >
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="../aaa/css/font.css">
    <link rel="stylesheet" href="../aaa/css/xadmin.css">
    <script type="text/javascript" src="../aaa/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../aaa/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <!--<form class="layui-form" action="/indent/insert" method="get">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>编号
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="ordersId" name="ordersId" required="required" lay-verify="required"
                           autocomplete="off" class="layui-input" >
                </div>
                <label class="layui-form-label">
                    <span class="x-red">*</span>审核状态
                </label>
                <div class="layui-input-inline">
                    <select name="statusid" class="layui-input-inline">
                        <option value="0">请选择</option>
                        <option th:each="a:${status}"
                                th:value="${a.statusid}"
                                th:text="${a.statusname}"></option>
                    </select>
                </div>
                <label class="layui-form-label">
                    <span class="x-red">*</span>单据日期
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="ordertime" class="layui-input" id="test1" placeholder="请选择日期" lay-key="1">
                </div>
                <label class="layui-form-label">
                    <span class="x-red">*</span>商品名
                </label>
                <div class="layui-input-inline">
                    <select name="commodityid" class="layui-input-inline">
                        <option value="0">请选择</option>
                        <option th:each="a:${com}" th:value="${a.commodityid}" th:text="${a.commodityname}"></option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>商品数量
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="Samnumber" name="Samnumber" required="required" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label">
                    <span class="x-red">*</span>包装供应商
                </label>
                <div class="layui-input-inline">
                    <select name="BsupId" class="layui-input" >
                        <option value="0">请选择</option>
                        <option th:each="a:${bsu}" th:value="${a.BsupId}" th:text="${a.BsupName}"></option>
                    </select>
                </div>
                <label class="layui-form-label">
                    <span class="x-red">*</span>包装数量
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="satypenumber" name="satypenumber" required="required" lay-verify="pass"
                           autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label">
                    <span class="x-red">*</span>物流公司
                </label>
                <div class="layui-input-inline">
                    <select name="logId" class="layui-input" >
                        <option value="0">请选择</option>
                        <option th:each="a:${log}" th:value="${a.logId}" th:text="${a.logname}"></option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>当前地址
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="orloc" name="orloc" required="required" lay-verify="pass"
                           autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label">
                    <span class="x-red">*</span>到达地址
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="arrloc" name="arrloc" required="required" lay-verify=""
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                    <button  class="layui-btn layui-btn-radius" lay-filter="add" lay-submit="" style="width: 200px;margin-left:550px">
                        增加
                    </button>
            </div>
        </form>-->
        <table class="layui-table layui-form">
            <thead>
            <tr>
                <th>编号</th>
                <th>分销商</th>
                <th>商品供应商</th>
                <th>商品详情</th>
                <th>包装类别</th>
                <th>包装供应商</th>
                <th>物流公司</th>
                <th>物流方式</th>
                <th>审核状态</th>
                <th>定金</th>
                <th>编辑</th>
            </thead>
            <tbody>
            <tr th:each="dis_need:${dis_need}">
                <td name="ordersId" th:text="${dis_need.dis_need_id}"></td>
                <td name="distributorid" th:value="${dis_need.Distributor.distributorid}" th:text="${dis_need.Distributor.distributorname}"></td>
                <td th:text="${dis_need.supplier.supName}"></td>
                <td name="ordertime" th:text="${dis_need.birth}" style="display: none"></td>
                <td name="commodityid" th:value="${dis_need.commodity.commodityid}" th:text="${dis_need.commodity.commodityname}"></td>
                <td name="Samnumber" th:text="${dis_need.Samnumber}" style="display: none"></td>
                <td th:text="${dis_need.Bcategory.Bcategoryname}"></td>
                <td name="BsupId" th:value="${dis_need.Bsupplier.BsupId}" th:text="${dis_need.Bsupplier.BsupName}" style="display: none"></td>
                <td name="satypenumber" th:text="${dis_need.satypenumber}" style=""></td>
                <td name="orloc" th:text="河南省新乡市红旗区" style="display: none"></td>
                <td name="arrloc" th:text="${dis_need.distributor.distloc}" style="display: none"></td>
                <td name="logId" th:value="${dis_need.logistics.logId}" th:text="${dis_need.logistics.logname}"></td>
                <td th:text="${dis_need.logmode.logmodename}"></td>
                <td name="statusid" th:value="${dis_need.statusl.statusid}" th:text="${dis_need.statusl.statusname}"></td>
                <td name="advance" th:text="(${dis_need.commodity.coprice}*${dis_need.Samnumber}+${dis_need.Bsupplier.Bsprice}*${dis_need.satypenumber})"></td>
                <td name="emp_id" th:text="9" style="display: none"></td>
                <td name="logparticularsid" th:text="${dis_need.logparticularsid}" style="display: none"></td>
                <td name="logmodeprice" th:text="${dis_need.logmode.logmodeprice}" style="display: none"></td>
                <td>
                    <a>
                        <a title="编辑" th:onclick="xadmin.open('修改用户','/indent/goAdds?dis_need_id='+'[(${dis_need.dis_need_id})]',1300,500)">
                            <i class="layui-icon">&#xe642;</i>
                        </a>
                    </a>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>
<center>
    <button class="layui-btn layui-btn-radius" style="width: 150px" onclick="batchDel()">提交</button>
</center>
<script>
    //点击批量删除执行批量删除的方法
    debugger
    function batchDel() {
        layer.confirm('确认要添加吗？',function() {
            var data1 = Array();
            var data2 = Array();
            var data3 = Array();
            var data4 = Array();
            var data5 = Array();
            var data6 = Array();
            var data7 = Array();
            var data8 = Array();
            var data9 = Array();
            var data10 = Array();
            var data11 = Array();
            var data12 = Array();
            var data13 = Array();
            var orderList = Array();
            $("td[name='ordersId']").each(function(){
                data1.push($(this).text())
            });
            $("td[name='statusid']").each(function(){
                data2.push($(this).attr("value"))
            });
            $("td[name='ordertime']").each(function(){
                data3.push($(this).text())
            });
            $("td[name='commodityid']").each(function(){
                data4.push($(this).attr("value"))
            });
            $("td[name='Samnumber']").each(function(){
                data5.push($(this).text())
            });
            $("td[name='BsupId']").each(function(){
                data6.push($(this).attr("value"))
            });
            $("td[name='satypenumber']").each(function(){
                data7.push($(this).text())
            });
            $("td[name='orloc']").each(function(){
                data8.push($(this).text())
            });
            $("td[name='arrloc']").each(function(){
                data9.push($(this).text())
            });
            $("td[name='logId']").each(function(){
                data10.push($(this).attr("value"))
            });
            $("td[name='advance']").each(function(){
                data11.push($(this).text())
            });
            $("td[name='logparticularsid']").each(function(){
                data12.push($(this).text())
            });
            $("td[name='logmodeprice']").each(function(){
                data13.push($(this).text())
            });
            var i = 0;
            $("td[name='emp_id']").each(function() {
                    orderList.push({
                        ordersId: data1[i],
                        statusid: data2[i],
                        ordertime: data3[i],
                        commodityid: data4[i],
                        Samnumber: data5[i],
                        BsupId: data6[i],
                        satypenumber:data7[i],
                        orloc: data8[i],
                        arrloc: data9[i],
                        logId: data10[i],
                        advance: data11[i],
                        logparticularsid:data12[i],
                        logmodeprice:data13[i],
                        emp_id: $(this).text()
                    }); i++

                }
            );
            // alert(data5)
            // alert(data6)
            $.ajax({
                url: '/indent/addpiliang?ordersId='+data1+"&logparticularsid="+data12+"&advance="+data11+"&logmodeprice="+data13,
                type: 'POST',
                data: JSON.stringify(orderList),
                dataType: 'json',
                contentType:"application/json",
                //发送到服务器的数据，对象必须为key/value的格式，jquery会自动转换为字符串格式
                success: function (result) {
                }
            });
            debugger
            layer.msg("添加成功", {
                icon: 6,
                time: 500
            }, function () {
                parent.window.location.reload();//重新页面
                // 获得frame索引
                var index = parent.layer.getFrameIndex(window.name);
                //关闭当前frame
                parent.layer.close(index);
            });
        })
    }
    /*//批量添加
    function f() {
        var data1 = Array();
        var data2 = Array();
        var data3 = Array();
        var data4 = Array();
        var data5 = Array();
        var data6 = Array();
        var data7 = Array();
        var data8 = Array();
        var data9 = Array();
        var data10 = Array();
        var data11 = Array();
        var data12 = Array();
        var orderList = Array();
        $("td[name='ordersId']").each(function(){
            data1.push($(this).text())
        });
        $("td[name='statusid']").each(function(){
            data2.push($(this).attr("value"))
        });
        $("td[name='ordertime']").each(function(){
            data3.push($(this).text())
        });
        $("td[name='commodityid']").each(function(){
            data4.push($(this).attr("value"))
        });
        $("td[name='Samnumber']").each(function(){
            data5.push($(this).text())
        });
        $("td[name='BsupId']").each(function(){
            data6.push($(this).attr("value"))
        });
        $("td[name='satypenumber']").each(function(){
            data7.push($(this).text())
        });
        $("td[name='orloc']").each(function(){
            data8.push($(this).text())
        });
        $("td[name='arrloc']").each(function(){
            data9.push($(this).text())
        });
        $("td[name='logId']").each(function(){
            data10.push($(this).attr("value"))
        });
        $("td[name='advance']").each(function(){
            data11.push($(this).text())
        });
        $("td[name='emp_id']").each(function(){
            data12.push($(this).text())
        });
        var i = 0;
        $("td[name='logparticularsid']").each(function() {
            orderList.push({
                ordersId: data1[i],
                statusid: data2[i],
                ordertime: data3[i],
                commodityid: data4[i],
                Samnumber: data5[i],
                BsupId: data6[i],
                satypenumber:data7[i],
                orloc: data8[i],
                arrloc: data9[i],
                logId: data10[i],
                advance: data11[i],
                emp_id:data12[i],
                logparticularsid: $(this).text()
                }); i++,
            alert(data5)
            }
        );
        $.ajax({
            //请求方式
            type: 'POST',
            //发送请求的地址
            url: '/indent/addpiliang',
            //服务器返回的数据类型
            dataType: 'json',
            contentType:"application/json",
            //发送到服务器的数据，对象必须为key/value的格式，jquery会自动转换为字符串格式
            data: JSON.stringify(orderList),
            success: function (data) {
            }
        });

    }*/
</script>
</body>

</html>
